import Vue from 'vue'
import Vuex from 'vuex'
import { menu } from "../data/menu.js";
import {number} from '../api/api.js'
Vue.use(Vuex)
const state = {
  tagList: [],
  breadcrumbList: [],
  menudata:menu,
  count:0
}
const getters = {
  tagList (state) {
    return state.tagList
  },
  breadcrumbList (state) {
    return state.breadcrumbList
  },
  menudata (state) {
    return state.menudata
  },
  count(state)
  {
    return state.count
  }
}
const mutations = {
  updateTagList (state, payload) {
    state.tagList = payload
  },
  updateBreadcrumbList (state, payload) {
    state.breadcrumbList = payload
  },
  SET_DATA(state, payload) {
    state.menudata = payload;
  },
  count(state, payload) {
    state.count = payload;
  }

}
const actions = {
 async fetchData({ commit }, payload) {
  if(localStorage.getItem('token'))
    {
      setTimeout(async() => {
        const user = JSON.parse(localStorage.getItem("user"))
        const area = user.fkDept;
        const city = user.fkDept.slice(0, 4);
        const params = {
         area: area,
         city: city,
       };
       const data = await number(params);
       commit("count", data.result);
         //获取上传保证金凭证信息接口
      }, 1500);
    }
  }
}

const store = new Vuex.Store({
  state,
  mutations,
  getters,
  actions
})

export default store
